package cn.yqn.order.controller;

import cn.yqn.basic.utils.LoginContext;
import cn.yqn.basic.utils.PageList;
import cn.yqn.order.domain.OrderPetAcquisition;
import cn.yqn.order.query.OrderPetAcquisitionQuery;
import cn.yqn.user.domain.Logininfo;
import cn.yqn.order.service.IOrderPetAcquisitionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/orderPetAcquisition")
public class OrderPetAcquisitionController {

    @Autowired
    private IOrderPetAcquisitionService orderPetAcquisitionService;

    @PostMapping
    public PageList<OrderPetAcquisition> queryPage(@RequestBody HttpServletRequest request, OrderPetAcquisitionQuery query) {
        try {
            Logininfo logininfo = LoginContext.getLogininfo(request);
            return orderPetAcquisitionService.loadAll(query, logininfo.getId());
        } catch (Exception e) {
            e.printStackTrace();
            return new PageList<OrderPetAcquisition>();
        }
    }
}
